package com.qingke.besuper;


import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;

@XmlRootElement(name="busuper")
@XmlAccessorType(XmlAccessType.FIELD)
public class BeSuper {
	@XmlElementWrapper(name="users")
	@XmlElement(name="user")
	private List<User> users;
	
	@XmlElementWrapper(name="questions")
	@XmlElement(name="question")
	private List<Question> questions;
	
	@XmlElementWrapper(name="answers")
	@XmlElement(name="answer")
	private List<Answer> answers;
	
	public BeSuper(){
		users = new ArrayList<User>();
		questions = new ArrayList<Question>();
		answers = new ArrayList<Answer>();
	}
	public List<User> getUsers() {
		return users;
	}
	public void setUsers(List<User> users) {
		this.users = users;
	}
	public List<Question> getQuestions() {
		return questions;
	}
	public void setQuestions(List<Question> questions) {
		this.questions = questions;
	}
	public List<Answer> getAnswers() {
		return answers;
	}
	public void setAnswers(List<Answer> answers) {
		this.answers = answers;
	}
}
@XmlRootElement(name="user")
@XmlAccessorType(XmlAccessType.FIELD)
class User{
	@XmlElement(name="name")
	private String name;
	@XmlElement(name="score")
	private int score;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getScore() {
		return score;
	}
	public void setScore(int score) {
		this.score = score;
	}
	@Override
	public String toString() {
		return "User [name=" + name + ", score=" + score + "]";
	}
	
}
@XmlRootElement(name="qusetion")
@XmlAccessorType(XmlAccessType.FIELD)
class Question{
	@XmlAttribute
	private long id;
	@XmlAttribute
	private String from;
	@XmlAttribute
	private boolean isSolved;
	@XmlValue
	private String context;
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getFrom() {
		return from;
	}
	public void setFrom(String from) {
		this.from = from;
	}
	public String getContext() {
		return context;
	}
	public void setContext(String context) {
		this.context = context;
	}
	public boolean isSolved() {
		return isSolved;
	}
	public void setSolved(boolean isSolved) {
		this.isSolved = isSolved;
	}
	public String toString() {
		return "[id=" + id + ", from=" + from + ", isSolved=" + isSolved + "] " + context;
	}
	
}
@XmlRootElement(name="answer")
@XmlAccessorType(XmlAccessType.FIELD)
class Answer{
	@XmlAttribute
	private long id;
	@XmlAttribute
	private String from;
	@XmlValue
	private String context;
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getFrom() {
		return from;
	}
	public void setFrom(String from) {
		this.from = from;
	}
	public String getContext() {
		return context;
	}
	public void setContext(String context) {
		this.context = context;
	}
	public String toString() {
		return "[id=" + id + ", from=" + from + "] " + context;
	}

}
